Is it possible to get a list of child DBEs from a DB variable? This is so they can be read from callback functions with a DB argument when not declared globally.
|
Re: Get DBE list form DB Seems like an odd requirement, not had trouble defining them globally. |
Re: Get DBE list form DB llandale - Wed Dec 22 16:11:15 EST 2010 Wondered if there was a way to do clever things with addr_ to 'attach' a property to a DB. I've used addr_ to 'pass' a DBE to a callback by setting and getting the DB Title but that gives the DB an ugly title. |
Re: Get DBE list form DB SystemAdmin - Thu Dec 23 06:41:45 EST 2010
In fact you can do a dialog "class" which defines properties to your handles. You can even do callback-properties, where the user program can supply a custom function that shall be called, when the user does something in a dialog. If you are interested, I can extend the example (below).
struct MyDialog {}
DxlObject DxlObjectOf (MyDialog D) { return (addr_ D) DxlObject }
DB get_DBHandle (MyDialog D) { return ((DxlObjectOf D)->"DBHandle") DB}
void set_DBHandle (MyDialog D, DB var) { (DxlObjectOf D)->"DBHandle" = var}
// Define the controls here
DBE get_Text (MyDialog D) { return ((DxlObjectOf D)->"TextField") DBE }
void set_Text (MyDialog D, DBE var) { (DxlObjectOf D)->"TextField" = var}
DBE get_Label (MyDialog D) { return ((DxlObjectOf D)->"Label") DBE }
void set_Label (MyDialog D, DBE var) { (DxlObjectOf D)->"Label" = var}
// .. repeat that for as many controls as you want ...
MyDialog createMyDialog_ () { DxlObject x = new(); return (addr_ x) MyDialog }
MyDialog BuildDialog (string title) {
MyDialog result = createMyDialog_();
DB diag = create title
set_DBHandle (result, diag)
DBE lab = label (diag, "My Label")
set_Label (result, lab)
DBE txt = field (diag, "Text", "", 40)
set_Text (result, txt)
return result
}
MyDialog diagA = BuildDialog "Hallo"
MyDialog diagB = BuildDialog "You"
realize get_DBHandle diagA
realize get_DBHandle diagB
set (get_Text diagA, "Text for Dialog A")
set (get_Text diagB, "Text for Dialog B")
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
|
Re: Get DBE list form DB Mathias Mamsch - Sat Jan 08 12:50:11 EST 2011
In fact you can do a dialog "class" which defines properties to your handles. You can even do callback-properties, where the user program can supply a custom function that shall be called, when the user does something in a dialog. If you are interested, I can extend the example (below).
struct MyDialog {}
DxlObject DxlObjectOf (MyDialog D) { return (addr_ D) DxlObject }
DB get_DBHandle (MyDialog D) { return ((DxlObjectOf D)->"DBHandle") DB}
void set_DBHandle (MyDialog D, DB var) { (DxlObjectOf D)->"DBHandle" = var}
// Define the controls here
DBE get_Text (MyDialog D) { return ((DxlObjectOf D)->"TextField") DBE }
void set_Text (MyDialog D, DBE var) { (DxlObjectOf D)->"TextField" = var}
DBE get_Label (MyDialog D) { return ((DxlObjectOf D)->"Label") DBE }
void set_Label (MyDialog D, DBE var) { (DxlObjectOf D)->"Label" = var}
// .. repeat that for as many controls as you want ...
MyDialog createMyDialog_ () { DxlObject x = new(); return (addr_ x) MyDialog }
MyDialog BuildDialog (string title) {
MyDialog result = createMyDialog_();
DB diag = create title
set_DBHandle (result, diag)
DBE lab = label (diag, "My Label")
set_Label (result, lab)
DBE txt = field (diag, "Text", "", 40)
set_Text (result, txt)
return result
}
MyDialog diagA = BuildDialog "Hallo"
MyDialog diagB = BuildDialog "You"
realize get_DBHandle diagA
realize get_DBHandle diagB
set (get_Text diagA, "Text for Dialog A")
set (get_Text diagB, "Text for Dialog B")
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
void ApplyButtonCallback(DB win)
|
Re: Get DBE list form DB SystemAdmin - Mon Jan 10 07:45:56 EST 2011
This is the sort of thing I had been playing with. It works but has the addr_ number as a title whick is not too nice.
/******************************************* ReportMessageBox ******************************************
Function Name: ReportMessageBox
Description: Displays a message box which can display a large message.
If necessary a scroll bar is displayed.
Parameters: TitleString - Title for Dialog Box
LabelString - Label of Text Message
MessageString - Message for Dialog Box
ConfirmButton - Confirm, Cancel Buttons rather than an OK Button
Result: Returns true unless Cancel is pressed.
*******************************************************************************************************/
bool ReportMessageBox(string TitleString, string LabelString, string MessageString, bool ConfirmButton)
{
bool Confirmed = true
DB ReportDB = create(TitleString, styleCentered|styleFloating)
Skip ListDBE = createString
setTitle(ReportDB, ((addr_(ListDBE)) int) "")
if(LabelString != "")
{
label(ReportDB, LabelString)
}
if(MessageString != "")
{
text(ReportDB, "", MessageString, 200, true)
}
void getCoffees(DBE CoffeeList)
{
int i = get CoffeeList
string s = get CoffeeList
// DB PassedDB = getParent(CoffeeList)
// setTitle(PassedDB, s)
if (i == 0) ack "Mmm, Mocha..."
if (i == 4) ack "Watch out for trademark violations"
}
void TestButtonClickCallback(DB PassedDB)
{
// Get the List BDE
string DBTitle = getTitle(PassedDB)
int Address = intOf(DBTitle)
Skip ListDBE = (addr_ Address) Skip
DBE aDBE
// Get the List
find(ListDBE, "CoffeeListDBE", aDBE)
// Read the Value
int i = get aDBE
string s = get aDBE
print i ": " s "\n"
}
void OKButtonClickCallback(DB PassedDB)
{
// Use the DB Title to get data out
setTitle(PassedDB, "True")
release(PassedDB)
}
void CancelButtonClickCallback(DB PassedDB)
{
// Use the DB Title to get data out
setTitle(PassedDB, "False")
release(PassedDB)
}
// List
string coffees[] = {"Mocha", "Sumatra Blue", "Mysore", "Kenya", "Java"}
DBE CoffeeListDBE = list(ReportDB, "Choose one of:", 4, coffees)
put(ListDBE, "CoffeeListDBE", CoffeeListDBE)
// run callback directly upon list selection
set(CoffeeListDBE, getCoffees)
apply(ReportDB, "Test", TestButtonClickCallback)
if(ConfirmButton)
{
ok(ReportDB, "Confirm", OKButtonClickCallback)
ok(ReportDB, "Cancel", CancelButtonClickCallback)
}
else
{
ok(ReportDB, "OK", OKButtonClickCallback)
}
// Hide Close Button
close(ReportDB, false, CancelButtonClickCallback)
realize(ReportDB) // Realize Dialogue Box in Memory - not yet visible
raise(ReportDB) // Ensures Dialogue Box appears infront of all other windows
block(ReportDB) // Show Dialog Box and freezes DOORS user interface - user can only react with DB.
// Execution Paused & Resumes Here After A Callback or "release(ReportDB)"
string DBTitle = getTitle(ReportDB)
if(DBTitle == "False")
{
Confirmed = false
}
delete ListDBE
release(ReportDB) // Releases Memory back to OS.
destroy(ReportDB)
ReportDB = null
return Confirmed
}
/**************************************** END ReportMessageBox ****************************************/
infoBox ReportMessageBox("TitleString", "Caption Text", "Message Text", true) ""
|
Re: Get DBE list form DB SystemAdmin - Mon Jan 10 07:45:56 EST 2011
Ok, I thought you were asking about having a dialog, without declaring the elements as global variables. So why would it be bad to have one global Skip list, which maps Dialogs (DB) to MyDialog or DBE text fields (your modified code, see below)? If you used the struct{} approach, you could just map the dialog handle (DB) to the MyDialog and then you could have as many dialog instances open as you want, access all DBEs in the dialog from all callbacks.
Skip gl_Button_to_List = create()
bool ReportMessageBox(string TitleString, string LabelString, string MessageString, bool ConfirmButton)
{
bool Confirmed = true
DB ReportDB = create(TitleString, styleCentered|styleFloating)
setTitle(ReportDB, TitleString)
if(LabelString != "") { label(ReportDB, LabelString) }
if(MessageString != "") { text(ReportDB, "", MessageString, 200, true) }
void getCoffees(DBE CoffeeList) {
int i = get CoffeeList
string s = get CoffeeList
if (i == 0) ack "Mmm, Mocha..."
if (i == 4) ack "Watch out for trademark violations"
}
void TestButtonClickCallback(DB PassedDB) {
DBE aDBE
find(gl_Button_to_List, PassedDB, aDBE)
int i = get aDBE
string s = get aDBE
print i ": " s "\n"
}
void OKButtonClickCallback(DB PassedDB) {
// Use the DB Title to get data out
setTitle(PassedDB, "True")
release(PassedDB)
}
void CancelButtonClickCallback(DB PassedDB) {
// Use the DB Title to get data out
setTitle(PassedDB, "False")
release(PassedDB)
}
// List
string coffees[] = {"Mocha", "Sumatra Blue", "Mysore", "Kenya", "Java"}
DBE CoffeeListDBE = list(ReportDB, "Choose one of:", 4, coffees)
// run callback directly upon list selection
set(CoffeeListDBE, getCoffees)
apply(ReportDB, "Test", TestButtonClickCallback)
put(gl_Button_to_List, ReportDB, CoffeeListDBE)
if(ConfirmButton) {
ok(ReportDB, "Confirm", OKButtonClickCallback)
ok(ReportDB, "Cancel", CancelButtonClickCallback)
} else {
ok(ReportDB, "OK", OKButtonClickCallback)
}
// Hide Close Button
close(ReportDB, false, CancelButtonClickCallback)
realize(ReportDB) // Realize Dialogue Box in Memory - not yet visible
raise(ReportDB) // Ensures Dialogue Box appears infront of all other windows
block(ReportDB) // Show Dialog Box and freezes DOORS user interface - user can only react with DB.
// Execution Paused & Resumes Here After A Callback or "release(ReportDB)"
string DBTitle = getTitle(ReportDB)
if(DBTitle == "False")
{
Confirmed = false
}
release(ReportDB) // Releases Memory back to OS.
destroy(ReportDB)
ReportDB = null
return Confirmed
}
/**************************************** END ReportMessageBox ****************************************/
infoBox ReportMessageBox("TitleString", "Caption Text", "Message Text", true) ""
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
|
Re: Get DBE list form DB Mathias Mamsch - Mon Jan 10 10:00:44 EST 2011
Ok, I thought you were asking about having a dialog, without declaring the elements as global variables. So why would it be bad to have one global Skip list, which maps Dialogs (DB) to MyDialog or DBE text fields (your modified code, see below)? If you used the struct{} approach, you could just map the dialog handle (DB) to the MyDialog and then you could have as many dialog instances open as you want, access all DBEs in the dialog from all callbacks.
Skip gl_Button_to_List = create()
bool ReportMessageBox(string TitleString, string LabelString, string MessageString, bool ConfirmButton)
{
bool Confirmed = true
DB ReportDB = create(TitleString, styleCentered|styleFloating)
setTitle(ReportDB, TitleString)
if(LabelString != "") { label(ReportDB, LabelString) }
if(MessageString != "") { text(ReportDB, "", MessageString, 200, true) }
void getCoffees(DBE CoffeeList) {
int i = get CoffeeList
string s = get CoffeeList
if (i == 0) ack "Mmm, Mocha..."
if (i == 4) ack "Watch out for trademark violations"
}
void TestButtonClickCallback(DB PassedDB) {
DBE aDBE
find(gl_Button_to_List, PassedDB, aDBE)
int i = get aDBE
string s = get aDBE
print i ": " s "\n"
}
void OKButtonClickCallback(DB PassedDB) {
// Use the DB Title to get data out
setTitle(PassedDB, "True")
release(PassedDB)
}
void CancelButtonClickCallback(DB PassedDB) {
// Use the DB Title to get data out
setTitle(PassedDB, "False")
release(PassedDB)
}
// List
string coffees[] = {"Mocha", "Sumatra Blue", "Mysore", "Kenya", "Java"}
DBE CoffeeListDBE = list(ReportDB, "Choose one of:", 4, coffees)
// run callback directly upon list selection
set(CoffeeListDBE, getCoffees)
apply(ReportDB, "Test", TestButtonClickCallback)
put(gl_Button_to_List, ReportDB, CoffeeListDBE)
if(ConfirmButton) {
ok(ReportDB, "Confirm", OKButtonClickCallback)
ok(ReportDB, "Cancel", CancelButtonClickCallback)
} else {
ok(ReportDB, "OK", OKButtonClickCallback)
}
// Hide Close Button
close(ReportDB, false, CancelButtonClickCallback)
realize(ReportDB) // Realize Dialogue Box in Memory - not yet visible
raise(ReportDB) // Ensures Dialogue Box appears infront of all other windows
block(ReportDB) // Show Dialog Box and freezes DOORS user interface - user can only react with DB.
// Execution Paused & Resumes Here After A Callback or "release(ReportDB)"
string DBTitle = getTitle(ReportDB)
if(DBTitle == "False")
{
Confirmed = false
}
release(ReportDB) // Releases Memory back to OS.
destroy(ReportDB)
ReportDB = null
return Confirmed
}
/**************************************** END ReportMessageBox ****************************************/
infoBox ReportMessageBox("TitleString", "Caption Text", "Message Text", true) ""
Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS
|